﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using emp.Utility;

public partial class crm_supporting_ProgressInImplementation : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        if(!IsPostBack)
        {
            //IList lists = new emp.BLL.Support().getWhzxjdb(null, null, null, null);
            //this.datalist.DataSource = lists;
            //this.datalist.DataBind();
            emp.Model.CampaignInfo campaignInfo = new emp.Model.CampaignInfo();
            IList data= new emp.BLL.Campaign().getCampaignList();
            
            this.camname.DataSource = data;
            this.camname.DataTextField = "CAM_NAME";
            this.camname.DataValueField = "CAM_UID";
            this.camname.DataBind();
            camname.Items.Insert(0, "全部");
            
            //zx();
        }
    }

    protected void savebt_Click(object sender, EventArgs e)
    {
        zx();
        
    }

    void zx() 
    {
        
        string chaname1 = "";
        string camname1 = "";
        if (this.chaname.SelectedIndex == 0)
        {
            chaname1 = "";
        }
        else
        {
            chaname1 = this.chaname.SelectedValue.ToString();
        }
        if (this.camname.SelectedIndex == 0)
        {
            camname1 = "";
        }
        else
        {
            camname1 = this.camname.SelectedValue.ToString();
        }

        //Response.Write("<script>alert('" + this.txtCreateDate_start.Value + "++++" + this.txtCreateDate_end.Value + "')</script>");
        IList lists = new emp.BLL.Support().getWhzxjdbDT1(this.txtCreateDate_start.Value, this.txtCreateDate_end.Value, camname1, chaname1);
        this.datalist.DataSource = lists;
        this.datalist.DataBind();
        HttpContext.Current.Session.Add("PagesFY", lists);

        PageUtil.setPageCount(datalist, lists.Count);
    }





    protected void datalist_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        datalist.PageIndex = PageUtil.getGviewNewPage(this.datalist, e.NewPageIndex);

        IList dt = null;
        if (HttpContext.Current.Session["PagesFY"] != null)
        {
            dt=(IList)HttpContext.Current.Session["PagesFY"];
        }
        this.datalist.DataSource = dt;
        this.datalist.DataBind();
        PageUtil.setPageCount(datalist, dt.Count);
       
    }
    protected void camname_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (this.camname.SelectedIndex == 0)
        {
            this.chaname.Items.Clear();

        }
        else 
        {
            emp.BLL.Support sup = new emp.BLL.Support();
            DataTable dt = sup.getChanameByCamname(this.camname.SelectedValue.ToString());
            this.chaname.DataSource = dt;
            this.chaname.DataTextField = "CHA_NAME";
            this.chaname.DataValueField = "CHA_UID";
            this.chaname.DataBind();
            chaname.Items.Insert(0, "请选择...");

        }
        
    }
}
